from fastapi import APIRouter, Request, Query
from app.movie.curd.movie_curd import curd_movie, curd_boxffice, curd_design
import json
from pydantic import BaseModel

router = APIRouter()


class Design(BaseModel):
    country: str
    date: str
    length: int
    director: str
    star1: str
    star2: str
    kind: str


@router.get('/all_info')
def search_all():
    return curd_movie.search_all()


@router.get('/realtime_search')
def realtime_search(item: Request, key=Query(''), deprecated=True):
    return curd_movie.realtime_search(item.query_params)


@router.get('/movie_realtime_search')
def movie_realtime_search(item: Request, key=Query('')):
    return curd_movie.movie_realtime_search(item.query_params)


@router.get('/today_rank')
def today_rank():
    return curd_movie.today_rank()


@router.get('/recommand')
def get_recommand(item: Request, key=Query('')):
    return curd_movie.get_recommand(item.query_params)


@router.get('/homepage')
def get_homepage():
    return curd_movie.get_homepage()


@router.get('/today_top5')
def get_today_top5():
    return curd_movie.get_today_top5()


@router.get('/unplay')
def get_unplay():
    return curd_movie.get_unplay()


@router.get('/actor')
def get_actor(item: Request, key=Query('')):
    return curd_movie.get_actor(item.query_params)


@router.get('/director')
def get_director(item: Request, key=Query('')):
    return curd_movie.get_director(item.query_params)


@router.get('/predict_boxoffice')
def get_predicted():
    return curd_boxffice()


@router.post('/selfDesign')
def predict_boxoffice(item: Design):
    return curd_design(item.dict())


@router.get('/getkind')
def get_kind():
    return curd_movie.get_kind()


@router.get('/detail_movie')
def get_detail(item:Request,name=Query('')):
    return curd_movie.get_detail(item.query_params)